import Vue from 'vue'
import Router from 'vue-router'
import iView from 'iview'
import simProblem from '@/pages/simProblem.vue'
import home from '@/pages/home.vue'
import ServeRecord from '@/pages/ServeRecord.vue'
import search from '@/pages/search.vue'
import proHome from '@/pages/proDetails/proHome.vue'
import proDetails from '@/pages/proDetails/proDetails.vue'
import introduce from '@/pages/proDetails/introduce/introduce.vue'
import orderIn from '@/pages/orderIn.vue'
import dispatch from '@/pages/dispatch.vue'
import err from '@/pages/errPage/err.vue'
import searchErr from '@/pages/errPage/searchErr.vue'
Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'home',
      meta:{title:'首页'},
      component: home
    },
    {
      path: '/simProblem',
      name: 'simProblem',
      meta:{title:'常见问题'},
      component: simProblem,
      redirect:"/simProblem/proHome",
      children:[
        {
          path:"proHome",
          name:"proHome",
          meta:{title:'常见问题'},
          component:proHome
        },
        {
          path:"proDetails",
          name:"proDetails",
          meta:{title:'常见问题'},
          component:proDetails
        },
        {
          path:"introduce",
          name:"introduce",
          meta:{title:'问题明细'},
          component:introduce
        },
        {
          path: 'search',
          name: 'search',
          meta:{title:'搜索'},
          component: search
        }
      ]
    },
    {
      path: '/ServeRecord',
      name: 'ServeRecord',
      meta:{title:'服务记录'},
      component: ServeRecord
    }
  ]
})


router.beforeEach((to, from, next) => {
document.title = to.meta.title;
iView.LoadingBar.start();
next();
});
router.afterEach(() => {

  iView.LoadingBar.finish();
})
export default router
